<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01列表渲染</title>
  <script src="../js/vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>{{title}}</h1>
    <h3>1遍历数组</h3>
    <ul>
      <li v-for="(p, index) in persons" :key="index">{{index}}-{{p.name}}-{{p.age}}</li>
    </ul>
    <br>
    <ul>
      <li v-for="p of persons" :key="p.id">{{p.name}}-{{p.age}}</li>
    </ul>
    <h3>2遍历对象</h3>
    <ul>
      <li v-for="(value, name) of car" :key="name">{{name}}-{{value}}</li>
    </ul>
    <h3>3遍历字符串</h3>
    <ul>
      <li v-for="(item, index) of str" :key="index">{{index}}-{{item}}</li>
    </ul>
    <h3>4遍历指定次数</h3>
    <ul>
      <li v-for="(item, index) of 10" :key="index">{{index}}-{{item}}</li>
    </ul>
  </div>
  <script>
    new Vue({
      el: '#app',
      data() {
        return {
          title: '列表渲染',
          persons: [
            {
              id: '001',
              name: 'zhangsan',
              age: 18
            },
            {
              id: '002',
              name: 'lisi',
              age: 18
            },
            {
              id: '003',
              name: 'wangwu',
              age: 18
            }
          ],
          car: {
            name: 'byd',
            color: 'black',
            price: '20w'
          },
          str: 'hello world'
        }
      }
    })
  </script>
</body>
</html>